import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import {JVxeTypes,JVxeColumn} from '/@/components/jeecg/JVxeTable/types'
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '项目',
    align:"center",
    dataIndex: 'projectId_dictText'
   },
   {
    title: '系统',
    align:"center",
    dataIndex: 'projectSystemId_dictText'
   },
   {
    title: '接口名称',
    align:"center",
    dataIndex: 'apiName'
   },
   {
    title: '请求方法',
    align:"center",
    dataIndex: 'requestMethods_dictText'
   },
   {
    title: '请求风格',
    align:"center",
    dataIndex: 'requestStyle_dictText'
   },
   {
    title: '关联功能',
    align:"center",
    dataIndex: 'functionId'
   },
   {
    title: 'url',
    align:"center",
    dataIndex: 'url'
   },
   {
    title: '数据格式',
    align:"center",
    dataIndex: 'requestDataType_dictText'
   },
   {
    title: '描述',
    align:"center",
    dataIndex: 'description'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '项目',
    field: 'projectId',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"tm_project,project_name,id"
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入项目!'},
          ];
     },
  },
  {
    label: '系统',
    field: 'projectSystemId',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"tm_project_system,system_name,id"
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入系统!'},
          ];
     },
  },
  {
    label: '接口名称',
    field: 'apiName',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入接口名称!'},
          ];
     },
  },
  {
    label: '请求方法',
    field: 'requestMethods',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"request_method"
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入请求方法!'},
          ];
     },
  },
  {
    label: '请求风格',
    field: 'requestStyle',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"request_style"
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入请求风格!'},
          ];
     },
  },
  {
    label: '关联功能',
    field: 'functionId',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入关联功能!'},
          ];
     },
  },
  {
    label: 'url',
    field: 'url',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入url!'},
          ];
     },
  },
  {
    label: '数据格式',
    field: 'requestDataType',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"request_data_type"
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入数据格式!'},
          ];
     },
  },
  {
    label: '描述',
    field: 'description',
    component: 'InputTextArea',
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];
//子表单数据
export const interfacePostParamFormSchema: FormSchema[] = [
  {
    label: '参数',
    field: 'body',
    component: 'InputTextArea',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入参数!'},
          ];
     },
  },
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];
//子表表格配置
export const interfaceHeaderColumns: JVxeColumn[] = [
    {
      title: '参数',
      key: 'param',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
        validateRules: [
          { required: true, message: '${title}不能为空' },
        ],
    },
    {
      title: '值',
      key: 'value',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '描述',
      key: 'description',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
  ]
export const interfaceGetParamColumns: JVxeColumn[] = [
    {
      title: '参数',
      key: 'param',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
        validateRules: [
          { required: true, message: '${title}不能为空' },
        ],
    },
    {
      title: '值',
      key: 'value',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '描述',
      key: 'description',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
  ]
export const interfacePreOperationColumns: JVxeColumn[] = [
    {
      title: '参数',
      key: 'param',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
        validateRules: [
          { required: true, message: '${title}不能为空' },
        ],
    },
    {
      title: '值',
      key: 'value',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '描述',
      key: 'description',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
  ]
export const interfacePostOperationColumns: JVxeColumn[] = [
    {
      title: '规则类型',
      key: 'ruleStyle',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
        validateRules: [
          { required: true, message: '${title}不能为空' },
        ],
    },
    {
      title: '取值对象',
      key: 'content',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '规则条件',
      key: 'ruleCondition',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
        validateRules: [
          { required: true, message: '${title}不能为空' },
        ],
    },
    {
      title: '值',
      key: 'value',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
        validateRules: [
          { required: true, message: '${title}不能为空' },
        ],
    },
    {
      title: '描述',
      key: 'description',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
        validateRules: [
          { required: true, message: '${title}不能为空' },
        ],
    },
  ]

// 高级查询数据
export const superQuerySchema = {
  projectId: {title: '项目',order: 0,view: 'list', type: 'string',dictTable: "tm_project", dictCode: 'id', dictText: 'project_name',},
  projectSystemId: {title: '系统',order: 1,view: 'list', type: 'string',dictTable: "tm_project_system", dictCode: 'id', dictText: 'system_name',},
  apiName: {title: '接口名称',order: 2,view: 'text', type: 'string',},
  requestMethods: {title: '请求方法',order: 3,view: 'list', type: 'string',dictCode: 'request_method',},
  requestStyle: {title: '请求风格',order: 4,view: 'list', type: 'string',dictCode: 'request_style',},
  functionId: {title: '关联功能',order: 5,view: 'text', type: 'string',},
  url: {title: 'url',order: 6,view: 'text', type: 'string',},
  requestDataType: {title: '数据格式',order: 7,view: 'list', type: 'string',dictCode: 'request_data_type',},
  description: {title: '描述',order: 8,view: 'textarea', type: 'string',},
  //子表高级查询
  interfaceHeader: {
    title: '请求头',
    view: 'table',
    fields: {
        param: {title: '参数',order: 0,view: 'text', type: 'string',},
        value: {title: '值',order: 1,view: 'text', type: 'string',},
        description: {title: '描述',order: 2,view: 'text', type: 'string',},
    }
  },
  interfaceGetParam: {
    title: 'Params',
    view: 'table',
    fields: {
        param: {title: '参数',order: 0,view: 'text', type: 'string',},
        value: {title: '值',order: 1,view: 'text', type: 'string',},
        description: {title: '描述',order: 2,view: 'text', type: 'string',},
    }
  },
  interfacePostParam: {
    title: 'Body',
    view: 'table',
    fields: {
        body: {title: '参数',order: 0,view: 'textarea', type: 'string',},
    }
  },
  interfacePreOperation: {
    title: '前置操作',
    view: 'table',
    fields: {
        param: {title: '参数',order: 0,view: 'text', type: 'string',},
        value: {title: '值',order: 1,view: 'text', type: 'string',},
        description: {title: '描述',order: 2,view: 'text', type: 'string',},
    }
  },
  interfacePostOperation: {
    title: '后置操作',
    view: 'table',
    fields: {
        ruleStyle: {title: '规则类型',order: 0,view: 'text', type: 'string',},
        content: {title: '取值对象',order: 1,view: 'text', type: 'string',},
        ruleCondition: {title: '规则条件',order: 2,view: 'text', type: 'string',},
        value: {title: '值',order: 3,view: 'text', type: 'string',},
        description: {title: '描述',order: 4,view: 'text', type: 'string',},
    }
  },
};
